using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FiltronASP.Models;
using FiltronASP.Models.DAO;
using FiltronASP.Models.DAO.WIX;
using FiltronASP.Models.DAO.Extensions;
using FiltronASP.Models.DAO.Interfaces.WIX;
using FiltronASP.Models.DAO.Interfaces;
using FiltronASP.Models.DAO.Filtron;
using FiltronASP.Models.DAO.Interfaces.Filtron;
using FiltronASP.Helpers.Translations;
using FiltronASP.Helpers.CatalogueHelpers;
using System.IO;
using System.Net;
using FiltronASP.Logger;
using FiltronASP.Helpers.ReplacementsHelper;
using System.Text;
using FiltronASP.Helpers.Instructions;

namespace FiltronASP.Helpers.AjaxModel
{
    /// <summary>
    /// Klasa pomocnicza do generowania stringa z lista modeli.
    /// </summary>
    public static class ModelHelper
    {

        /// <summary>
        /// Metoda generujaca string do comba na podstawie id marki.
        /// </summary>
        /// <param name="makeId">marka</param>
        /// <returns>string</returns>
        public static string GetModelComboString(int makeId, string languageName)
        {
            string comboString = "";
            comboString += translationHelper.getTranslation("_selectModel", languageName) + "| -1;";
            IWixModelDAO wixModelDAO = new WixModelDAO();
            if (makeId > 0)
            {
                IQueryable<WixModel> wixModels = wixModelDAO.FindByMake(makeId);
                foreach (WixModel model in wixModels)
                {
                    comboString += model.model_name.TrimEnd(',');
                    comboString += "|";
                    comboString += model.model_id;
                    comboString += ";";

                }   //foreach
            }   //if
            return comboString;
        }

        /// <summary>
        /// Metoda generujaca string do comba na podstawie id marki.
        /// </summary>
        /// <param name="makeId">marka</param>
        /// <returns>string</returns>
        public static string GetMonthComboString(string year, string languageName)
        {

            string comboString = "";

            IPageDAO PageDAO = new PageDAO();
            IQueryable<Page> MonthsCollection = PageDAO.FindByLanguageAndTemplateNameAndPublished(7, "NewsSingleMonth", true);
            List<String> MonthsList = new List<String>();
            if (MonthsCollection != null)
            {
                MonthsCollection = MonthsCollection.OrderBy(p => p.page_ordering);
                foreach (Page singleMonth in MonthsCollection)
                {
                    MonthsList.Add(singleMonth.page_name);
                }
            }
            comboString += translationHelper.getTranslation("_chooseMonth", languageName) + "| -1;";
            if (MonthsList != null)
            {
                List<String> YearList = new List<String>();
                foreach (String currentMonth in MonthsList)
                {
                    String splittedMonth = currentMonth.Split(' ')[0];
                    String splittedYear = currentMonth.Split(' ')[1];
                    if (splittedYear.Equals(year))
                    {
                        comboString += GlobalHelper.TranslateMonths(splittedMonth, languageName);
                        comboString += "|";
                        comboString += splittedMonth;
                        comboString += ";";
                    }
                }
            }
            return comboString;
        }

        public static string GetImplementationsTableForMonth(string month, string languageName)
        {
            if (month == "")
            {
                return null;
            }
            if (languageName == "")
            {
                return null;
            }
            string htmlToReturn = "";

            htmlToReturn += "<!--                                nagłówek-->";
            htmlToReturn += "<div class=\"col-xs-12 no-padding\">";
            htmlToReturn += "  <div class=\"col-sm-12 col-xs-12 no-padding overlay-engine2 \">";
            htmlToReturn += "      <div class=\" col-md-2 col-xs-3 no-padding \">";
            htmlToReturn += String.Format("      <p>{0}</p>", translationHelper.getTranslation("_newsFilterNumber", languageName));
            htmlToReturn += "    </div>";
            htmlToReturn += " <div class=\"col-md-2 col-xs-2 no-padding overlay-engine-boder-r overlay-engine-boder-l\">";
            htmlToReturn += String.Format("    <p>{0}</p>", translationHelper.getTranslation("_newsType", languageName)); //type
            htmlToReturn += " </div>";
            htmlToReturn += "<div class=\" col-md-6 col-xs-4 no-padding overlay-engine-boder-r\">";
            htmlToReturn += String.Format(" <p>{0}<p>", translationHelper.getTranslation("_newsMainApplication", languageName));   //apl

            htmlToReturn += " </div>";
            htmlToReturn += "<div class=\"col-md-2 col-xs-3 no-padding overlay-engine-boder-r\" style=\"border-right: 1px solid #000;\">";
            htmlToReturn += String.Format("<p>{0}</p>", translationHelper.getTranslation("_downloadPDF", languageName)); //download
            htmlToReturn += "</div>";
            htmlToReturn += "</div>";

            htmlToReturn += "</div>";
            htmlToReturn += "<!--nagłwek-->";





            return htmlToReturn;//Helpers.AjaxModel.EngineTableHelper.generateEngineTable(modelId, languageName);
        }

        /// <summary>
        /// Metoda generujaca diva leftSearchSide do silnikow na podstawie id modelu.
        /// </summary>
        /// <param name="modelId">model</param>
        /// <returns>string</returns>
        public static string GetEngineDivString(int modelId, string languageName)
        {
            if (modelId.Equals(0))
            {
                return null;
            }
            if (languageName == String.Empty)
            {
                return null;
            }

            return Helpers.AjaxModel.EngineTableHelperWIX.generateEngineTable(modelId, languageName);
        }

        /// <summary>
        /// Metoda generujaca diva leftSearchSide do silnikow.
        /// </summary>
        /// <returns>string</returns>
        public static string GetEngineDivString()
        {
            return String.Empty;
        }

        /// <summary>
        /// Metoda generująca listę marek na podstawie typu pojazdu. (vehicle)
        /// </summary>
        /// <param name="vehicleId">typ pojazdu</param>
        /// <returns>string</returns>
        public static string getBrandDropDownByVehicleId(int vehicleId, string languageName)
        {
            string comboString = translationHelper.getTranslation("_selectManufacturer", languageName) + ",-1;";
            IWixMakeDAO wixMakesDAO = new WixMakeDAO();
            if (vehicleId > 0)
            {
                IQueryable<WixMake> wixMakes = wixMakesDAO.FindByVehicle(vehicleId);
                foreach (WixMake make in wixMakes)
                {
                    comboString += make.make_name;
                    comboString += ",";
                    comboString += make.make_id;
                    comboString += ";";
                }
            }

            return comboString;
        }

        public static string GetFiltersByEngineAndModel(int engineId, int modelId, string languageName)
        {

            if (engineId.Equals(0))
            {
                return null;
            }
            if (modelId.Equals(0))
            {
                return null;
            }
            if (languageName == "")
            {
                return null;
            }
            return Helpers.AjaxModel.FiltersTableHelperWIX.generateFiltersTable(engineId, modelId, languageName);
        }

        public static string generateSingleFilter(int filterId, string languageName)
        {
            IWixFilterDAO wixFilterDAO = new WixFilterDAO();
            WixFilter filter = wixFilterDAO.FindByPK(filterId);
            if (filter == null)
            {
                return String.Empty;
            }   //if
            StringBuilder sb = new StringBuilder();

            string filterXML750 = HttpContext.Current.Server.MapPath("~/Content/Assets/Filters/" + filter.filter_number + "/0750/" + filter.filter_number + "_out.xml");
            string filterXML1500 = HttpContext.Current.Server.MapPath("~/Content/Assets/Filters/" + filter.filter_number + "/1500/" + filter.filter_number + "_out.xml");
            if (File.Exists(filterXML750))
            {
                sb.Append(String.Format("<div id='container360' class='threesixty car' data-number='{0}'>", filter.filter_number));
                sb.Append("<div class='slider-filter-name'>");
                sb.Append(String.Format("<p>{0}</p>", filter.filter_number));
                sb.Append("</div>");
                sb.Append("<div class='spinner'>");
                sb.Append("<span>0%</span>");
                sb.Append("</div>");
                sb.Append("<ol class='threesixty_images'></ol>");
                sb.Append("</div>");
                if (File.Exists(filterXML1500))
                {
                    sb.Append(String.Format("<div id='container360fullscreen' style='display: none;' class='threesixty car' data-number='{0}'>", filter.filter_number));
                    sb.Append("<div class='slider-filter-name'>");
                    sb.Append(String.Format("<p>{0}</p>", filter.filter_number));
                    sb.Append("</div>");
                    sb.Append("<div class='spinner'>");
                    sb.Append("<span>0%</span>");
                    sb.Append("</div>");
                    sb.Append("<ol class='threesixty_images'></ol>");
                    sb.Append("</div>");
                }
            }
            else
            {
                filterXML750 = HttpContext.Current.Server.MapPath("~/Content/Assets/Filters/" + filter.filter_number + "/0750/3648_out.xml");
                filterXML1500 = HttpContext.Current.Server.MapPath("~/Content/Assets/Filters/" + filter.filter_number + "/1500/3648_out.xml");
                if (File.Exists(filterXML750))
                {
                    sb.Append(String.Format("<div id='container360' class='threesixty car' data-number='{0};3648'>", filter.filter_number));
                    sb.Append("<div class='slider-filter-name'>");
                    sb.Append(String.Format("<p>{0}</p>", filter.filter_number));
                    sb.Append("</div>");
                    sb.Append("<div class='spinner'>");
                    sb.Append("<span>0%</span>");
                    sb.Append("</div>");
                    sb.Append("<ol class='threesixty_images'></ol>");
                    sb.Append("</div>");
                    if (File.Exists(filterXML1500))
                    {
                        sb.Append(String.Format("<div id='container360fullscreen' style='display: none;' class='threesixty car' data-number='{0};3648'>", filter.filter_number));
                        sb.Append("<div class='slider-filter-name'>");
                        sb.Append(String.Format("<p>{0}</p>", filter.filter_number));
                        sb.Append("</div>");
                        sb.Append("<div class='spinner'>");
                        sb.Append("<span>0%</span>");
                        sb.Append("</div>");
                        sb.Append("<ol class='threesixty_images'></ol>");
                        sb.Append("</div>");
                    }
                }
                else
                {
                    string imageFilter = HttpContext.Current.Server.MapPath("~/Content/img/filters/" + filter.filter_number + ".png");
                    if (File.Exists(imageFilter))
                    {
                        sb.Append("<div id='notfound360' style='width: 100%; text-align: center;' class='col-xs-12'>");
                        sb.Append(String.Format("<a href='{0}' data-lightbox='image-1' data-title='{1}'>", VirtualPathUtility.ToAbsolute("~/Content/img/filters/" + filter.filter_number + ".png"), filter.filter_number));
                        sb.Append("<img src='" + VirtualPathUtility.ToAbsolute("~/Content/img/filters/thumbnails/" + filter.filter_number + ".png") + "' alt='' />");
                        sb.Append(String.Format("<img class='no-360-magnifi' src='{0}' alt='lupa'>", VirtualPathUtility.ToAbsolute("~/Content/img/lupa-yellow.png")));
                        sb.Append("</a>");
                        sb.Append("</div>");
                    }
                    else
                    {
                        if (languageName == "polish")
                        {
                            sb.Append("<div id='notfound360' style='width: 100%; height: 500px; text-align: center;' class='col-xs-12'><img style='position: relative; top: 100px;' src='" + VirtualPathUtility.ToAbsolute("~/Content/img/temp/example_filter.png") + "' alt='' /></div>");
                        }
                        else
                        {
                            sb.Append("<div id='notfound360' style='width: 100%; height: 500px; text-align: center;' class='col-xs-12'><img style='position: relative; top: 100px;' src='" + VirtualPathUtility.ToAbsolute("~/Content/img/temp/example_filter_english.png") + "' alt='' /></div>");
                        }   //else
                    }
                }
            }

            sb.Append("<div class='col-xs-12 no-padding under-360-gallery'>");
            // ### SMALL IMAGES ###
            sb.Append(SingleFilterImagesHelper.generateFirstFilterPhoto(filter.filter_number, languageName));
            sb.Append(SingleFilterImagesHelper.generateSecondFilterPhoto(filter.filter_number, languageName));
            sb.Append(SingleFilterImagesHelper.generateThirdFilterPhoto(filter.filter_number, languageName));
            sb.Append(SingleFilterImagesHelper.generateFourthFilterPhoto(filter.filter_number, languageName));
            // ### SMALL IMAGES ###

            sb.Append("</div>");
            sb.Append("<div class='col-xs-12 desc-filter no-padding'>");
            sb.Append("<div class='col-md-12 col-xs-12' id='desc-filter-dim-id'>");

            sb.Append(String.Format("<h4>{0} (MM):</h4>", translationHelper.getTranslation("_hlpSizes", languageName).ToUpper()));

            if (filter.filter_outside_dia_top > 0)
            {
                sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
                sb.Append(String.Format("<span>{0}: </span><span>{1}</span>", translationHelper.getTranslation("_outerDiamaterTop", languageName), SingleFilterHelper.parseFilterSizes(SingleFilterHelper.convertInchesToMetric(filter.filter_outside_dia_top))));
                sb.Append("</div>");
            }
            else
            {
                sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
                sb.Append(String.Format("<span>{0}: </span><span>{1}</span>", translationHelper.getTranslation("_outerDiamaterTop", languageName), "---"));
                sb.Append("</div>");
            }

            if (filter.filter_outside_dia_bottom > 0)
            {
                sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
                sb.Append(String.Format("<span>{0}: </span><span>{1}</span>", translationHelper.getTranslation("_outerDiamaterBottom", languageName), SingleFilterHelper.parseFilterSizes(SingleFilterHelper.convertInchesToMetric(filter.filter_outside_dia_bottom))));
                sb.Append("</div>");
            }
            else
            {
                sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
                sb.Append(String.Format("<span>{0}: </span><span>{1}</span>", translationHelper.getTranslation("_outerDiamaterBottom", languageName), "---"));
                sb.Append("</div>");
            }
            if (filter.filter_inside_dia_top > 0)
            {
                sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
                sb.Append(String.Format("<span>{0}: </span><span>{1}</span>", translationHelper.getTranslation("_innerDiameterTop", languageName), SingleFilterHelper.parseFilterSizes(SingleFilterHelper.convertInchesToMetric(filter.filter_inside_dia_top))));
                sb.Append("</div>");
            }
            else
            {
                sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
                sb.Append(String.Format("<span>{0}: </span><span>{1}</span>", translationHelper.getTranslation("_innerDiameterTop", languageName), "---"));
                sb.Append("</div>");
            }
            if (filter.filter_inside_dia_bottom > 0)
            {
                sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
                sb.Append(String.Format("<span>{0}: </span><span>{1}</span>", translationHelper.getTranslation("_innerDiameterBottom", languageName), SingleFilterHelper.parseFilterSizes(SingleFilterHelper.convertInchesToMetric(filter.filter_inside_dia_bottom))));
                sb.Append("</div>");
            }
            else
            {
                sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
                sb.Append(String.Format("<span>{0}: </span><span>{1}</span>", translationHelper.getTranslation("_innerDiameterBottom", languageName), "---"));
                sb.Append("</div>");
            }
            if (filter.filter_height > 0)
            {
                sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
                sb.Append(String.Format("<span>{0}: </span><span>{1}</span>", translationHelper.getTranslation("_height", languageName), SingleFilterHelper.parseFilterSizes(SingleFilterHelper.convertInchesToMetric(filter.filter_height))));
                sb.Append("</div>");
            }
            else
            {
                sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
                sb.Append(String.Format("<span>{0}: </span><span>{1}</span>", translationHelper.getTranslation("_height", languageName), "---"));
                sb.Append("</div>");
            }

            if (filter.filter_thread_size != null)
            {
                sb.Append("<div class='dimen-v2 padd-l-0 dimen-item'>");
                sb.Append(String.Format("<span>{0}: </span><span>{1}</span>", translationHelper.getTranslation("_threadSize", languageName), filter.filter_thread_size));
                sb.Append("</div>");
            }
            sb.Append("</div>");
            sb.Append("<div class='col-md-12 col-xs-12' id='desc-filter-appl-id'>");
            sb.Append(String.Format("<h4>{0}:</h4>", translationHelper.getTranslation("_hlpApplication", languageName).ToUpper()));
            sb.Append("<div class='dimen-v2 dimen-item'>");
            sb.Append(String.Format("<span style='font-weight: normal'>{0}</span>", filter.filter_principle_applications));
            sb.Append("</div>");
            sb.Append("</div>");

            string filterStyle = "---";
            string filterType = "---";
            string filterMedia = "---";
            string filterService = "---";
            if ((filter.filter_style_id > 0) && (filter.filter_style_id != null))
            {
                filterStyle = SingleFilterHelper.getFilterStyle(Convert.ToInt32(filter.filter_style_id));
            }
            if ((filter.filter_type_id > 0) && (filter.filter_type_id != null))
            {
                filterType = SingleFilterHelper.getFilterType(Convert.ToInt32(filter.filter_type_id));
            }
            if ((filter.filter_media_id > 0) && (filter.filter_media_id != null))
            {
                filterMedia = SingleFilterHelper.getMediaType(Convert.ToInt32(filter.filter_media_id));
            }
            if ((filter.filter_service_id > 0) && (filter.filter_service_id != null))
            {
                filterMedia = SingleFilterHelper.getFilterService(Convert.ToInt32(filter.filter_service_id));
            }

            sb.Append("<div class='col-md-12 col-xs-12' id='desc-filter-other-id'>");
            sb.Append(String.Format("<h4>{0}:</h4>", translationHelper.getTranslation("_hlpOther", languageName).ToUpper()));

            sb.Append("<div class='col-xs-12 no-padding'>");
            sb.Append(String.Format("<span class='dimen-other-title'>{0}: </span><span class='dimen-other-text'>{1}</span>", translationHelper.getTranslation("_hlpFilterStyle", languageName), filterStyle));
            sb.Append("</div>");

            sb.Append("<div class='col-xs-12 no-padding'>");
            sb.Append(String.Format("<span class='dimen-other-title'>{0}: </span><span class='dimen-other-text'>{1}</span>", translationHelper.getTranslation("_hlpFilterType", languageName), filterType));
            sb.Append("</div>");

            sb.Append("<div class='col-xs-12 no-padding'>");
            sb.Append(String.Format("<span class='dimen-other-title'>{0}: </span><span class='dimen-other-text'>{1}</span>", translationHelper.getTranslation("_hlpFilterMedia", languageName), filterMedia));
            sb.Append("</div>");

            sb.Append("<div class='col-xs-12 no-padding'>");
            sb.Append(String.Format("<span class='dimen-other-title'>{0}: </span><span class='dimen-other-text'>{1}</span>", translationHelper.getTranslation("_hlpFilterService", languageName), filterService));
            sb.Append("</div>");

            sb.Append("</div>");
            sb.Append("</div>");
            if (filter != null)
            {
                sb.Append(String.Format("<div style='display:none' id='desc-filter-number-id'>{0}</div>", filter.filter_number));
            }   //if

            sb.Append(generatePopup(generatePopupInfoLogisticsContent(filterId, "popupClose", languageName), "popupLogisticsInfo", "popupClose", false, 220));
            sb.Append(generatePopup(ModelHelper.generatePopupOeNumbersContentFiltron(filterId, "popupOeClose"), "popupOeNumbers", "popupOeClose", true));
            sb.Append(generatePopup(ModelHelper.generatePopupMail(filterId, "popupMailClose", languageName), "popupMail", "popupMailClose", true));
            sb.Append(generatePopup(ModelHelper.generatePopupFullSizeGallery(filterId, "popupGalClose"), "popupGal", "popupGallClose", true));
            return sb.ToString();
        }



        public static string generateReplacementInfo(int filterId, string filterProducer, string languageName)
        {
            if ((filterId.Equals(0)) || (filterProducer == ""))
            {
                return null;
            }
            if (filterProducer == "w")
            {
                IWixFilterDAO WixFilterDAO = new WixFilterDAO();
                WixFilter filter = WixFilterDAO.FindByPK(filterId);
                return filter.filter_number;
            }
            if (filterProducer == "f")
            {
                IFiltronFilterDAO FiltronFilterDAO = new FiltronFilterDAO();
                FiltronFilter filter = FiltronFilterDAO.FindByPK(filterId);
                return FiltronHelper.GetFiltronFilterWixNumber(filter.filter_wix_number, filter.filter_wix_number_hd);
            }
            return null;

        }

        public static string generateReplacementDescription(int filterId, string filterProducer, string languageName)
        {
            if ((filterId.Equals(0)) || (filterProducer == ""))
            {
                return null;
            }

            string htmlToReturn = "";
            string imgPath = HttpContext.Current.Request.PhysicalApplicationPath + @"\Content\images\filters\";
            if (filterProducer == "w")
            {
                IWixFilterDAO wixFilterDAO = new WixFilterDAO();
                WixFilter filter = wixFilterDAO.FindByPK(filterId);
                htmlToReturn += "<div class=\"replacementsDescription\">";
                htmlToReturn += "<div class=\"searchRightSideTop\" id=\"searchRightSideTop\">";
                htmlToReturn += "                <div id=\"searchRightSideTopLeft\">";



                htmlToReturn += "                    <h3>" + translationHelper.getTranslation("_filter", languageName) + " <span>" + filter.filter_number + "</span></h3>";
                htmlToReturn += "                    <div class=\"searchRightSideTopLeftDimensions\">";
                htmlToReturn += "                        <strong>" + translationHelper.getTranslation("_hlpSizes", languageName) + " (mm):</strong>";
                htmlToReturn += "                        <table>";
                if (filter.filter_outside_dia_top > 0)
                {
                    htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_outerDiamaterTop", languageName) + ": <span>" + SingleFilterHelper.parseFilterSizes(SingleFilterHelper.convertInchesToMetric(filter.filter_outside_dia_top)) + "</span></td></tr>";
                }
                else
                {
                    htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_outerDiamaterTop", languageName) + ": <span> --- </span></td></tr>";
                }

                if (filter.filter_outside_dia_bottom > 0)
                {
                    htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_outerDiamaterBottom", languageName) + ": <span>" + SingleFilterHelper.parseFilterSizes(SingleFilterHelper.convertInchesToMetric(filter.filter_outside_dia_bottom)) + "</span></td></tr>";
                }
                else
                {
                    htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_outerDiamaterBottom", languageName) + ": <span> --- </span></td></tr>";
                }
                if (filter.filter_inside_dia_top > 0)
                {
                    htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_innerDiameter", languageName) + ": <span>" + SingleFilterHelper.parseFilterSizes(SingleFilterHelper.convertInchesToMetric(filter.filter_inside_dia_top)) + "</span></td></tr>";
                }
                else
                {
                    htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_innerDiameter", languageName) + ": <span> --- </span></td></tr>";
                }
                if (filter.filter_height > 0)
                {
                    htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_height", languageName) + ": <span>" + SingleFilterHelper.parseFilterSizes(SingleFilterHelper.convertInchesToMetric(filter.filter_height)) + "</span></td></tr>";
                }
                else
                {
                    htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_height", languageName) + ": <span> --- </span></td></tr>";
                }
                if (filter.filter_thread_size != null)
                {
                    htmlToReturn += "                            <tr><td style=\"width: 290px;\">" + translationHelper.getTranslation("_threadSize", languageName) + ": <span>" + filter.filter_thread_size + "</span></td></tr>";
                }
                htmlToReturn += "                        </table>";
                htmlToReturn += "                    </div>";
                htmlToReturn += "                    <div class=\"searchRightSideTopLeftInfo\">";
                htmlToReturn += "                        <ul>";

                string filterStyle = "---";
                string filterType = "---";
                string filterMedia = "---";
                string filterService = "---";
                if ((filter.filter_style_id > 0) && (filter.filter_style_id != null))
                {
                    filterStyle = SingleFilterHelper.getFilterStyle(Convert.ToInt32(filter.filter_style_id));
                }
                if ((filter.filter_type_id > 0) && (filter.filter_type_id != null))
                {
                    filterType = SingleFilterHelper.getFilterType(Convert.ToInt32(filter.filter_type_id));
                }
                if ((filter.filter_media_id > 0) && (filter.filter_media_id != null))
                {
                    filterMedia = SingleFilterHelper.getMediaType(Convert.ToInt32(filter.filter_media_id));
                }
                if ((filter.filter_service_id > 0) && (filter.filter_service_id != null))
                {
                    filterMedia = SingleFilterHelper.getFilterService(Convert.ToInt32(filter.filter_service_id));
                }

                string filterImg = "temp/example_filter_english";
                if (languageName == "polish")
                {
                    filterImg = "temp/example_filter";
                }
                string filterLargeImg = "temp/example_filter_english";
                if (languageName == "polish")
                {
                    filterLargeImg = "temp/example_filter";
                }
                if (File.Exists(imgPath + @"thumbnails\" + filter.filter_number + ".png"))
                {
                    filterImg = "filters/thumbnails/" + filter.filter_number + ".png";
                }   //if
                if (File.Exists(imgPath + filter.filter_number + ".png"))
                {
                    filterLargeImg = "filters/" + filter.filter_number + ".png";
                }   //if
                htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpFilterStyle", languageName) + ": <span>{0}</span></li>", filterStyle);
                htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpFilterType", languageName) + ": <span>{0}</span></li>", filterType);
                htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpFilterMedia", languageName) + ": <span>{0}</span></li>", filterMedia);
                htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpFilterService", languageName) + ": <span>{0}</span></li>", filterService);

                htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpInstruction", languageName) + ": <span>{0}</span></li>", String.Empty);
                htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpApplication", languageName) + ":<br/><span>{0}</span></li>", filter.filter_principle_applications);
                htmlToReturn += "                        </ul>";
                htmlToReturn += "                    </div>";
                htmlToReturn += "                    <div class=\"searchRightSideTopLeftCommands\">";
                htmlToReturn += "                        <img onclick=\"printFilterDescription()\" src=\"../../../Content/images/engine_printer.jpg\" alt=\"Printer\" /> <span onclick=\"printFilterDescription()\" class=\"desc_commands\">" + translationHelper.getTranslation("_hlpPrint", languageName) + "</span>";
                htmlToReturn += "                        <img src=\"../../../Content/images/engine_mail.jpg\" alt=\"Mail\" /> <span class=\"desc_commands\">" + translationHelper.getTranslation("_hlpSend", languageName) + "</span>";
                htmlToReturn += "                        <img onclick=\"" + showPopup("popupLogisticsInfo") + "\" src=\"../../../Content/images/logistics.png\" alt=\"Logistics Info\" /><span onclick=\"" + showPopup("popupLogisticsInfo") + "\" class=\"desc_commands\">Logistics Info</span>";  //bez translacji
                htmlToReturn += "                    </div>";
                htmlToReturn += "                </div>";
                htmlToReturn += "                <div id=\"searchRightSideTopRight\">";
                htmlToReturn += "                    <img src=\"../../../Content/images/" + filterImg + "\" alt=\"Example\" />";
                htmlToReturn += "                    <a href=\"../../../Content/images/" + filterLargeImg + "\" rel=\"lightbox\"><span>" + translationHelper.getTranslation("_hlpZoom", languageName) + " <img src=\"../../../Content/images/engine_magn.png\" alt=\"Zoom\" /></a></span>";
                htmlToReturn += "                </div>";
                htmlToReturn += "            </div>";
                htmlToReturn += "</div>";
                htmlToReturn += "<div class=\"replacementAlert\">" + translationHelper.getTranslation("_replacementAlert", languageName) + "</div>";
                htmlToReturn += generatePopup(generatePopupInfoLogisticsContent(filterId, "popupClose", languageName), "popupLogisticsInfo", "popupClose", false, 220);
                return htmlToReturn;
            }

            if (filterProducer == "f")
            {
                IFiltronFilterDAO filtronFilterDAO = new FiltronFilterDAO();
                FiltronFilter filter = filtronFilterDAO.FindByPK(filterId);
                htmlToReturn += "<div class=\"replacementsDescription\">";
                htmlToReturn += "<div class=\"searchRightSideTop\" id=\"searchRightSideTop\">";
                htmlToReturn += "                <div id=\"searchRightSideTopLeft\">";
                htmlToReturn += "                    <h3>" + translationHelper.getTranslation("_filter", languageName) + " <span>" + FiltronHelper.GetFiltronFilterWixNumber(filter.filter_wix_number, filter.filter_wix_number_hd) + "</span></h3>";
                htmlToReturn += "                    <div class=\"searchRightSideTopLeftDimensions\">";
                htmlToReturn += "                        <strong>" + translationHelper.getTranslation("_hlpSizes", languageName) + " (mm):</strong>";
                htmlToReturn += "                        <table>";
                string sizeG = String.Empty;
                string sizeF = String.Empty;
                if (filter.filter_dim_g_text != null) { sizeG = filter.filter_dim_g_text; } else { sizeG = Convert.ToString(SingleFilterHelper.parseFilterSizes(filter.filter_dim_g)); }
                if (filter.filter_dim_f_text != null) { sizeF = filter.filter_dim_f_text; } else { sizeF = Convert.ToString(SingleFilterHelper.parseFilterSizes(filter.filter_dim_f)); }

                htmlToReturn += "                            <tr><td>A: <span>" + SingleFilterHelper.parseFilterSizes(filter.filter_dim_a) + "</span></td><td>B: <span>" + SingleFilterHelper.parseFilterSizes(filter.filter_dim_b) + "</span></td><td>C: <span>" + SingleFilterHelper.parseFilterSizes(filter.filter_dim_c) + "</span></td></tr>";
                htmlToReturn += "                            <tr><td>D: <span>" + SingleFilterHelper.parseFilterSizes(filter.filter_dim_d) + "</span></td><td>E: <span>" + SingleFilterHelper.parseFilterSizes(filter.filter_dim_e) + "</span></td><td>F: <span>" + sizeF + "</span></td></tr>";
                htmlToReturn += "                            <tr><td>G: <span>" + sizeG + "</span></td><td>H: <span>" + SingleFilterHelper.parseFilterSizes(filter.filter_dim_h) + "</span></td></tr>";
                htmlToReturn += "                        </table>";
                htmlToReturn += "                    </div>";
                htmlToReturn += "                    <div class=\"searchRightSideTopLeftInfo\">";
                htmlToReturn += "                        <ul>";

                string byPassValve = translationHelper.getTranslation("_hlpNo", languageName);
                string antiDrain = translationHelper.getTranslation("_hlpNo", languageName);
                string antiSyphon = translationHelper.getTranslation("_hlpNo", languageName);
                if (filter.filter_by_pass_valve == true)
                {
                    byPassValve = translationHelper.getTranslation("_hlpYes", languageName);
                }
                if (filter.filter_anti_drain_valve == true)
                {
                    antiDrain = translationHelper.getTranslation("_hlpYes", languageName);
                }
                if (filter.filter_anti_siphon_valve == true)
                {
                    antiSyphon = translationHelper.getTranslation("_hlpYes", languageName);
                }

                string filtronName = FiltronHelper.GetFiltronFilterWixNumber(filter.filter_wix_number, filter.filter_wix_number_hd);

                htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpByPassValve", languageName) + ": <span>{0}</span></li>", byPassValve);
                htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpAntiDrain", languageName) + ": <span>{0}</span></li>", antiDrain);
                htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpAntiSiphon", languageName) + ": <span>{0}</span></li>", antiSyphon);
                string instructionPdf = FilterInstructions.getFilterInstruction(filtronName, Convert.ToString(filter.filter_number_trim));
                if (instructionPdf.Length > 0)
                {
                    htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpInstruction", languageName) + ": <span><a href=\"{0}\">Download</a></span></li>", instructionPdf);
                }
                else
                {
                    htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpInstruction", languageName) + ": <span>{0}</span></li>", "None");
                }
                htmlToReturn += String.Format("<li>" + translationHelper.getTranslation("_hlpApplication", languageName) + ":<br/><span>{0}</span></li>", filter.filter_principle_applications);
                htmlToReturn += "                        </ul>";
                htmlToReturn += "                    </div>";
                htmlToReturn += "                    <div class=\"searchRightSideTopLeftCommands\">";
                htmlToReturn += "                        <img onclick=\"printFilterDescription()\" src=\"../../../Content/images/engine_printer.jpg\" alt=\"Printer\" /> <span onclick=\"printFilterDescription()\" class=\"desc_commands\">" + translationHelper.getTranslation("_hlpPrint", languageName) + "</span>";
                htmlToReturn += "                        <img onclick=\"sendFilterDescription()\" src=\"../../../Content/images/engine_mail.jpg\" alt=\"Mail\" /> <span onclick=\"sendFilterDescription()\" class=\"desc_commands\">" + translationHelper.getTranslation("_hlpSend", languageName) + "</span>";
                htmlToReturn += "                    </div>";
                htmlToReturn += "                    <div class=\"searchRightSideTopLeftCommands\">";
                htmlToReturn += "                        <img onclick=\"" + showPopup("popupLogisticsInfo") + "\" src=\"../../../Content/images/logistics.png\" alt=\"Logistics Info\" /><span onclick=\"" + showPopup("popupLogisticsInfo") + "\" class=\"desc_commands\">Logistics Info</span>";  //bez translacji
                htmlToReturn += "                        <img onclick=\"" + ModelHelper.showPopup("popupOeNumbers") + "\" src=\"../../../Content/images/oe.png\" alt=\"OE\" /> <span onclick=\"" + ModelHelper.showPopup("popupOeNumbers") + "\" class=\"desc_commands\">OE</span>";
                htmlToReturn += "                    </div>";
                htmlToReturn += "                </div>";

                string imgPathFiltron = @"http://wixeurope.com/Content/images/filters/Filtron/" + FiltronHelper.GetFiltronFilterNumber(filter) + ".jpg";
                string imgUrl = String.Empty;
                string imgUrlLarge = String.Empty;
                bool showZoom = true;
                var request = (HttpWebRequest)WebRequest.Create(imgPathFiltron);
                request.Method = "HEAD";
                try
                {
                    var response = (HttpWebResponse)request.GetResponse();
                    imgUrl = imgPathFiltron;
                    imgUrlLarge = @"http://wixeurope.com/Content/images/filters/Filtron/large/" + FiltronHelper.GetFiltronFilterNumber(filter) + ".jpg";
                }
                catch
                {
                    IFiltronFilterMediaDAO filtronFilterMediaDAO = new FiltronFilterMediaDAO();
                    FiltronFilterMedia filterMedia = filtronFilterMediaDAO.FindByPK(filter.filter_media_id);
                    string orgFilterMedia = String.Empty;
                    if (filterMedia != null)
                    {
                        orgFilterMedia = filterMedia.media_name;
                        string RepImageName = FiltronHelper.GetFiltronFilterImage(orgFilterMedia);
                        imgUrl = String.Format(@"http://wixeurope.com/Content/images/filters/Filtron/{0}.jpg", RepImageName);
                    }
                    showZoom = false;
                }

                htmlToReturn += "                <div id=\"searchRightSideTopRightFiltron\">";
                htmlToReturn += "                    <img src=\"" + imgUrl + "\" alt=\"Example\" />";
                if (showZoom)
                    htmlToReturn += "                    <a href=\"" + imgUrlLarge + "\" rel=\"lightbox\"><span>" + translationHelper.getTranslation("_hlpZoom", languageName) + " <img src=\"../../../Content/images/engine_magn.png\" alt=\"Zoom\" /></a></span>";
                htmlToReturn += "                </div>";
                htmlToReturn += "            </div>";
                htmlToReturn += "</div>";
                htmlToReturn += "<div class=\"replacementAlert\">" + translationHelper.getTranslation("_replacementAlert", languageName) + "</div>";
                htmlToReturn += generatePopup(generatePopupInfoLogisticsContentFiltron(filterId, "popupClose", languageName), "popupLogisticsInfo", "popupClose", false, 220);
                htmlToReturn += generatePopup(ModelHelper.generatePopupOeNumbersContentFiltron(filterId, "popupOeClose"), "popupOeNumbers", "popupOeClose", true);
                return htmlToReturn;
            }

            return null;

        }

        public static string generatePopup(string popupContent, string popupId, string popupCloseId, bool withScroll)
        {
            return generatePopup(popupContent, popupId, popupCloseId, withScroll, 265);
        }

        public static string generatePopup(string popupContent, string popupId, string popupCloseId, bool withScroll, int height)
        {
            string htmlToReturn = String.Format("<div class='modal fade' id='{0}' role='dialog'>", popupId);

            htmlToReturn += "<div class='modal-dialog'>";
            htmlToReturn += "<div class='modal-content' style='float: left'>";



            /*content from 'popupContent' function*/
            if (!String.IsNullOrEmpty(popupContent))
            {
                htmlToReturn += popupContent;
            }

            htmlToReturn += "</div>";
            htmlToReturn += "</div>"; //modal-dialog
            htmlToReturn += "</div>";//modal fade
            /*  string htmlToReturn = String.Format("<div class='{0} popupOverlay'>", popupId);
              htmlToReturn += "<div style='position:relative; z-index:502; top:50%; left:50%;'>";
              htmlToReturn += String.Format("<div class='popupSelectContainer' style='position:absolute; z-index:503; top:-120px; left:-320px; width:410px; padding:20px; background:#ffffff; height:{0}px;'>", height);
              if (!String.IsNullOrEmpty(popupContent))
              {
                  htmlToReturn += popupContent;
              }   //if
              htmlToReturn += "</div>";
              htmlToReturn += "</div>";
              htmlToReturn += "</div>";
              htmlToReturn += "<script>";
              htmlToReturn += "( function($) {";
              htmlToReturn += "$(document).ready( function() { $('." + popupCloseId + "').click(function (e) { $('." + popupId + "').hide(); });  ";
              htmlToReturn += "}); } ) ( jQuery );";
              htmlToReturn += "</script>";*/

            return htmlToReturn;
        }
        public static string generatePopupFullSizeGallery(int filterId, string popupCloseId)
        {
            string htmlToReturn = "";
            htmlToReturn += " <div class='modal-header'>";
            htmlToReturn += "      <button type='button' class='close' data-dismiss='modal'>&times;</button>";
            htmlToReturn += "      <h4 class='modal-title'></h4>";
            htmlToReturn += "</div>";
            htmlToReturn += "        <div class='modal-body'>";
            htmlToReturn += "   <div class='car2 threesixty'>";
            htmlToReturn += "<ol class='threesixty_images' id='threesixty_images2'>";
            htmlToReturn += "</ol>";

            htmlToReturn += "</div>";
            htmlToReturn += "<div class='under-360-gallery'>";
            htmlToReturn += "      <button type='button' class='close' data-dismiss='modal'>&times;</button>";
            htmlToReturn += " </div>";
            htmlToReturn += "</div>";


            return htmlToReturn;
        }


        public static string generatePopupInfoLogisticsContent(int filterId, string popupCloseId, string languageName)
        {
            string htmlToReturn = "";
            htmlToReturn += " <div class='modal-header'>";
            htmlToReturn += "      <button type='button' class='close' data-dismiss='modal'>&times;</button>";
            htmlToReturn += "      <h4 class='modal-title'>" + translationHelper.getTranslation("_catLogisticInfoTitle", languageName) + "</h4>";
            htmlToReturn += "</div>";
            htmlToReturn += "   <div class=\"col-xs-12 mCustomScrollbar\" data-mcs-theme=\"dark\">";
            htmlToReturn += "  <div class='col-xs-12'>";
            htmlToReturn += "        <div class='modal-body'>";

            WixLogisticsInfo info = getLogisticsInfo(filterId);
            if (info == null)
            {
                htmlToReturn += "<div class='col-xs-12'>No info to display.</div>";
            }
            else
            {
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticGroup", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.hd);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticMinOrder", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.min_ilosc_zam);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticPalletAmount", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.ilosc_pal);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticCardboardWidth", languageName));;
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.kart_w);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticCardboardHeight", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.kart_h);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticCardboardLength", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.kart_l);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticCardboardWeight", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.waga);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticEAN", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.kod_ean);
                htmlToReturn += "</div>";
            }
            htmlToReturn += "</div>";
            htmlToReturn += "</div>";
            htmlToReturn += "</div>";
            htmlToReturn += "<div class='modal-footer'></div>";
            return htmlToReturn;
        }

        public static string generatePopupInfoLogisticsContentFiltron(int filterId, string popupCloseId, string languageName)
        {
            string htmlToReturn = "";

            htmlToReturn += " <div class='modal-header'>";
            htmlToReturn += "      <button type='button' class='close' data-dismiss='modal'>&times;</button>";
            htmlToReturn += "      <h4 class='modal-title'>" + translationHelper.getTranslation("_catLogisticInfoTitle", languageName) + "</h4></div>";

            htmlToReturn += "   <div class=\"col-xs-12 mCustomScrollbar\" data-mcs-theme=\"dark\">";
            htmlToReturn += "  <div class='col-xs-12'>";
            htmlToReturn += "        <div class='modal-body'>";


            FiltronLogisticsInfo info = getLogisticsInfoFiltron(filterId);
            if (info == null)
            {
                htmlToReturn += "<div class='col-xs-12'>No info to display.</div>";
            }
            else
            {

                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticGroup", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.hd);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticMinOrder", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.min_ilosc_zam);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticPalletAmount", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.ilosc_pal);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticCardboardWidth", languageName)); ;
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.kart_w);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticCardboardHeight", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.kart_h);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticCardboardLength", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.kart_l);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticCardboardWeight", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.waga);
                htmlToReturn += "</div>";
                htmlToReturn += "<div class='col-xs-12 filer-modal-over'>";
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", translationHelper.getTranslation("_catLogisticEAN", languageName));
                htmlToReturn += String.Format("<div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", info.kod_ean);
                htmlToReturn += "</div>";
            }
            htmlToReturn += "</div>";
            htmlToReturn += "</div>";
            htmlToReturn += "</div>";
            htmlToReturn += "<div class='modal-footer'></div>";
            return htmlToReturn;
        }

        public static string showPopup(string popupId)
        {
            string htmlToReturn = "( function($) {";
            htmlToReturn += "$(document).ready( function() { $('." + popupId + "').show();  } );";
            htmlToReturn += "} ) ( jQuery );";
            return htmlToReturn;
        }

        private static WixLogisticsInfo getLogisticsInfo(int filterId)
        {
            try
            {
                WixLogisticsInfoDAO logisticsDAO = new WixLogisticsInfoDAO();
                IQueryable<WixLogisticsInfo> logisticsInfos = logisticsDAO.FindByFilterId(filterId);
                if (logisticsInfos == null)
                {
                    return null;
                }   //if
                foreach (WixLogisticsInfo logisticInfo in logisticsInfos)
                {
                    return logisticInfo;
                }   //for                
            }
            catch (Exception ex)
            {
                MyLogger.Log(ex);
            }
            return null;
        }

        private static FiltronLogisticsInfo getLogisticsInfoFiltron(int filterId)
        {
            try
            {
                FiltronLogisticsInfoDAO logisticsDAO = new FiltronLogisticsInfoDAO();
                IQueryable<FiltronLogisticsInfo> logisticsInfos = logisticsDAO.FindByFilterId(filterId);
                if (logisticsInfos == null)
                {
                    return null;
                }   //if
                foreach (FiltronLogisticsInfo logisticInfo in logisticsInfos)
                {
                    return logisticInfo;
                }   //for                
            }
            catch (Exception ex)
            {
                MyLogger.Log(ex);
            }
            return null;
        }

        public static string generatePopupOeNumbersContentFiltron(int filterId, string popupCloseId)
        {
            List<Replacement> replacements = ReplacementList.generateReplacementListFiltronOe(filterId);
            int rowsCount = 0;

            string htmlToReturn = "";

            htmlToReturn += " <div class='modal-header'>";
            htmlToReturn += "      <button type='button' class='close' data-dismiss='modal'>&times;</button>";
            htmlToReturn += "      <h4 class='modal-title'>OE Numbers</h4></div>";
            htmlToReturn += "  <div class='col-xs-12'>";
            htmlToReturn += "        <div class='modal-body content'>";

            if (replacements == null)
            {
                htmlToReturn += "<div class='col-xs-12'><p>No numbers to display.</p></div>";
            }
            else if (replacements.Count == 0)
            {
                htmlToReturn += "<div class='col-xs-12'><p>No numbers to display.</p></div>";
            }
            else
            {
                int counter = 0;
                foreach (Replacement replacement in replacements)
                {
                    htmlToReturn += " <div class='col-xs-12 filer-modal-over'>";
                    htmlToReturn += String.Format(" <div class='col-xs-6 no-padding text-right filer-modal-left'><p>{0}</p></div>", replacement.foreignFilterManufacturer);
                    htmlToReturn += String.Format(" <div class='col-xs-6 no-padding text-left filer-modal-right'><p>{0}</p></div>", replacement.foreignFilter);
                    htmlToReturn += "</div>";
                    counter++;
                    if (counter >= 20)
                    {
                        htmlToReturn += " <div class='col-xs-12 filer-modal-over'>";
                        htmlToReturn += String.Format(" <div class='col-xs-12'>and many more...</div>");
                        htmlToReturn += "</div>";
                        break;
                    }   //if
                }   //for
                rowsCount = replacements.Count;
            }
            htmlToReturn += "</div>";
            htmlToReturn += "</div>";
            htmlToReturn += "<div class='modal-footer'></div>";
            return htmlToReturn;
        }

        public static string generatePopupMail(int filterId, string popupCloseId, string languageName)
        {
            string htmlToReturn = "";
            htmlToReturn += " <div class='modal-header'>";
            htmlToReturn += "      <button type='button' class='close' data-dismiss='modal'>&times;</button>";
            htmlToReturn += String.Format("      <h4 class='modal-title' style='color: #fcb320'>{0}</h4></div>", translationHelper.getTranslation("_hlpSend", languageName));
            htmlToReturn += "        <div class='modal-body' style='border: none; border-top: 1px solid #fcb320;'>";
            htmlToReturn += "  <div class='col-xs-12' style='margin-top: 20px'>";
            htmlToReturn += "<div class='col-xs-12'><div class='col-sm-6 col-xs-12'><span style='font-weight: normal; color: #fcb320; font-size: 13px;'>Send to(email):</span></div><div class='col-sm-6 col-xs-12'><input style='width: 100%' id='email' type='email' name='email'/></div></div>";
            htmlToReturn += "</div>";
            htmlToReturn += "  <div class='col-xs-12' style='margin-top: 20px'>";
            htmlToReturn += "<div class='col-xs-12'><div class='col-sm-6 col-xs-12'><span style='font-weight: normal; color: #fcb320; font-size: 13px;'>Your name:</span></div><div class='col-sm-6 col-xs-12'> <input style='width: 100%' id='from' name='from'/></div></div>";
            htmlToReturn += "</div>";
            htmlToReturn += "  <div class='col-xs-12' style='margin-top: 20px; margin-bottom: 20px;'>";
            htmlToReturn += "  <div class='col-sm-2 col-xs-12'>";
            htmlToReturn += String.Format("<div style='cursor: pointer; text-decoration: none; text-align: center; color: #fff;border: 2px solid #fcb320; background-color: #fcb320; padding: 5px 15px 5px 15px;' onclick='sendFilterDescription()'><span style='font-weight: 300!important; color: #fff !important;'>{0}</span></div>", translationHelper.getTranslation("_hlpSend", languageName));
            htmlToReturn += "</div>";
            htmlToReturn += "</div>";
            htmlToReturn += "</div>";
            return htmlToReturn;
        }

        public static string GetVehiclesComboString(string market, string languageName)
        {
            string comboString = translationHelper.getTranslation("_mainSearchSelectVehicleType", languageName) + "|-1;";
            if (String.IsNullOrEmpty(market))
            {
                return comboString;
            }   //if
            if (market.ToLower() == "w")
            {
                comboString += translationHelper.getTranslation("_mainSearchPassengerText", languageName) + "|7;";
                comboString += translationHelper.getTranslation("_mainSearchTruckText", languageName) + "|8;";
                comboString += translationHelper.getTranslation("_mainSearchMachineText", languageName) + "|6;";
                comboString += translationHelper.getTranslation("_mainSearchOtherText", languageName) + "|11;";
                comboString += translationHelper.getTranslation("_mainSearchMotorcyclesText", languageName) + "|9;";
                comboString += translationHelper.getTranslation("_mainSearchAtvsText", languageName) + "|10;";
                return comboString;
            }   //wix
            if (market.ToLower() == "f")
            {
                comboString += translationHelper.getTranslation("_mainSearchPassengerText", languageName) + "|2;";
                comboString += translationHelper.getTranslation("_mainSearchTruckText", languageName) + "|3;";
                comboString += translationHelper.getTranslation("_mainSearchMachineText", languageName) + "|1;";
                comboString += translationHelper.getTranslation("_mainSearchOtherText", languageName) + "|11;";
                comboString += translationHelper.getTranslation("_mainSearchMotorcyclesText", languageName) + "|9;";
                comboString += translationHelper.getTranslation("_mainSearchAtvsText", languageName) + "|10;";
                return comboString;
            }   //wix
            return comboString;
        }

    }
}
